package com.supermap.business.cloud.loginlog;

import com.alibaba.dubbo.config.annotation.Reference;
import com.supermap.dataservice.util.JSONUtil;
import com.supermap.dataservice.util.Table;
import com.supermap.dubbo.api.cloud.loginlog.LoginLogService;
import com.supermap.dubbo.api.cloud.loginlog.loginlog;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author aqua
 * @description
 * @date 2018年12月04 上午 10:33
 * @email 1301584033@qq.com
 */
@Controller
@RequestMapping("/cloud/loginlog")
public class LoginLogController {
    @Reference(timeout = 100000)
    private LoginLogService loginLogService;
    /**
     * 入库
     * */
    @PutMapping("/insertLoginLog")
    @ResponseBody
    public JSONUtil insertLoginLog(@RequestBody loginlog loginlog){
        return  loginLogService.insertLoginLog(loginlog);
    }


    /**
     *指定区域和时间范围内用户最近一次登录查询(含登录总次数)
     * */
    @GetMapping("/getPageLoginLogByUserIdAndareaCodeOrdTime")
    @ResponseBody
    public JSONUtil getLoginLogByUserIdAndareaCodeAndTime(String areaCode,String beginTime,String endTime,Integer pageNum,Integer pageSize){
        return  loginLogService.getLoginLogByUserIdAndareaCodeOrdTime(areaCode,beginTime,endTime,pageNum,pageSize);
    }



    /**
     *指定用户和时间范围内所有登录日志查询
     * */
    @GetMapping("/getPageAllLoginLogByUserIdorTime")
    @ResponseBody
    public JSONUtil getPageAllLoginLogByUserIdandTime(String userId,String beginTime,String endTime,Integer pageNum,Integer pageSize){
        return  loginLogService.getPageAllLoginLogByUserIdorTime(userId,beginTime,endTime,pageNum,pageSize);
    }

    /**
     * 获取系统登陆日志,sms展示
     * **/
    @RequestMapping("/getSysLoginLog")
    @ResponseBody
    public Table getSysLoginLog(loginlog loginlog,Table table){
        JSONUtil jsonUtil = loginLogService.getSysLoginLog(loginlog,table);
        table = (Table) jsonUtil.getData();
        table.setMsg(jsonUtil.getMsg());
        table.setCode(jsonUtil.getCode());
        return table;
    }

}
